package architecture.base.interceptors;
/**
 * 通过继承AbstractInterceptor，实现授权拦截器
 */
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import architecture.base.context.ActionServiceContext;

@Service("authorInterceptor")
public class AuthorInterceptor extends AbstractInterceptor{
	
	private static final Log log = LogFactory.getLog(AuthorInterceptor.class);
	/**
	 * 
	 */
	private static final long serialVersionUID = 4672350402427085215L;

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		// TODO Auto-generated method stub
		Object username = ActionServiceContext.getSessionAttribute("username");
		if(username != null){
			log.info("e");
			return  invocation.invoke();
		}else{
			return "login";
		}
	}

}
